package application.common.render;

import com.jfinal.kit.StrKit;

import application.common.model.User;
import javafx.beans.property.SimpleStringProperty;

public final class UserProperty {

	private final SimpleStringProperty id = new SimpleStringProperty();
	private final SimpleStringProperty username = new SimpleStringProperty();
	private final SimpleStringProperty name = new SimpleStringProperty();
	private final SimpleStringProperty roleKey = new SimpleStringProperty();
	private final SimpleStringProperty roleName = new SimpleStringProperty();
	private final SimpleStringProperty authorityName = new SimpleStringProperty();
	
	public UserProperty(User user) {
		id.set(user.getId());
		username.set(user.getUsername());
		name.set(user.getName());
		roleKey.set(user.getRoleKey());
		roleName.set(user.getRoleName());
		String l="";
		if(user.getRoleKey().contains("setting")) {
			l+="系统管理";
		}
		if(user.getRoleKey().contains("all")) {
			if(!StrKit.isBlank(l)) {
				l+="，卷宗管理员";
			}else {
				l+="卷宗管理员";
			}
		}else {
			if(!StrKit.isBlank(l)) {
				l+="，卷宗用户";
			}else {
				l+="卷宗用户";
			}
		}
		authorityName.set(l);
	}

	public String getId() {
		return id.get();
	}

	public String getUsername() {
		return username.get();
	}

	public String getName() {
		return name.get();
	}

	public String getRoleKey() {
		return roleKey.get();
	}

	public String getRoleName() {
		return roleName.get();
	}

	public String getAuthorityName() {
		return authorityName.get();
	}


}
